/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.proyecto;

import com.proyecto.datos.EntityHorarioMat;
import com.proyecto.datos.EntityMateria;
import com.proyecto.datos.EntityPlan;
import com.proyecto.modelado.DetalleHorarioMateria;
import com.proyecto.modelado.Materia;
import com.proyecto.modelado.Plan;
import com.proyecto.reportes.rptIAF_FIS1_U1;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author mario
 */
public class frmRPT extends javax.swing.JInternalFrame {
    
    int id_materia1 = 0;
    int id_materia2 = 0;
    int id_plan1;
    int id_plan2;
    int id_grupo;
    String entNombreMateria1;
    String entNombreMateria2;
    DetalleHorarioMateria detaMate;
    EntityHorarioMat entDetaMate;
    rptIAF_FIS1_U1 rptUnidad1;
    Materia mate;
    EntityMateria entMate;
    Plan pla;
    EntityPlan entPla;
    
    public void PopularTable(int id_materia1) {
        DefaultTableModel tabla1;
        Object[] fila = new Object[3];
        try {
            String[] columName = {"Grupo", "Horario", "Catedratico"};
            tabla1 = new DefaultTableModel(null, columName);
            //populamos el arraylist de la tabla
            ArrayList arry_10 = new ArrayList();
            detaMate = new DetalleHorarioMateria();
            EntityHorarioMat entDetaMate = new EntityHorarioMat();
            
            arry_10 = detaMate.MostrarGruposMateriarpt_tble(id_materia1);
            if (arry_10 != null) {
                for (int i = 0; i < arry_10.size(); i++) {
                    entDetaMate = (EntityHorarioMat) arry_10.get(i);
                    fila[0] = entDetaMate.getGrupo();
                    fila[1] = entDetaMate.getEntHorario();
                    fila[2] = entDetaMate.getEntCatedratico().concat(" ").concat(entDetaMate.getEntCatedraticoApellido());
                    
                    
                    tabla1.addRow(fila);
                }
                
                
                
                
                this.jtbleGrupos.setModel(tabla1);
            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la base de datos", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.toString());
        }
    }
    
    public void BloquearControl() {
        this.jtxtGrupo.setEnabled(false);
    }
    
    public void LimpiarFrm() {
        this.jtxtGrupo.setText("");
        this.jtxtGrupo.setEnabled(false);
    }
    
    public void cargarComboboxPlan() {
        
        ArrayList arryPlan = new ArrayList();
        pla = new Plan();
        arryPlan = pla.MostrarPlan();
        JList list_rad = new JList();
        DefaultListModel listModel_rad = new DefaultListModel();
        
        listModel_rad.addElement("Seleccione");
        if (arryPlan != null) {
            for (int i = 0; i < arryPlan.size(); i++) {
                entPla = (EntityPlan) arryPlan.get(i);
                listModel_rad.addElement(entPla.getNombre_plan());
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Materia", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
        }
        list_rad.setModel(listModel_rad);

        //seteando dos combos con los planes

        this.jcmbPlan1.setModel(new DefaultComboBoxModel(listModel_rad.toArray()));
        this.jcmbPlan1.setSelectedIndex(0);
        
        this.jcmbPlan2.setModel(new DefaultComboBoxModel(listModel_rad.toArray()));
        this.jcmbPlan2.setSelectedIndex(0);
    }
    
    public void CargarComboMaterias1(int id_plan1) {
        ArrayList arryMate = new ArrayList();
        mate = new Materia();
        arryMate = mate.MostrarMaterias_Param_Plan(id_plan1);
        JList list = new JList();
        DefaultListModel listModel = new DefaultListModel();
        
        listModel.addElement("Seleccione");
        if (arryMate != null) {
            for (int i = 0; i < arryMate.size(); i++) {
                entMate = (EntityMateria) arryMate.get(i);
                listModel.addElement(entMate.getCodigo_asignatura());
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Materia", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
        }
        list.setModel(listModel);

        //seteando dos combos con los planes

        this.jcmbMaterias1.setModel(new DefaultComboBoxModel(listModel.toArray()));
        this.jcmbMaterias1.setSelectedIndex(0);
        
    }
    
    public void CargarComboMaterias2(int id_plan2) {
        ArrayList arryMate = new ArrayList();
        mate = new Materia();
        arryMate = mate.MostrarMaterias_Param_Plan(id_plan2);
        JList list = new JList();
        DefaultListModel listModel = new DefaultListModel();
        
        listModel.addElement("Seleccione");
        if (arryMate != null) {
            for (int i = 0; i < arryMate.size(); i++) {
                entMate = (EntityMateria) arryMate.get(i);
                listModel.addElement(entMate.getCodigo_asignatura());
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Materia", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
        }
        list.setModel(listModel);

        //seteando dos combos con los planes

        this.jcmbMaterias2.setModel(new DefaultComboBoxModel(listModel.toArray()));
        this.jcmbMaterias2.setSelectedIndex(0);
        
    }
    
    public frmRPT() {
        initComponents();
        BloquearControl();
        cargarComboboxPlan();
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jbtnGenerarRPT = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtbleGrupos = new javax.swing.JTable();
        jcmbUnidad = new javax.swing.JComboBox();
        jcmbMaterias2 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jtxtGrupo = new javax.swing.JTextField();
        jcmbMaterias1 = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jcmbPlan1 = new javax.swing.JComboBox();
        jcmbPlan2 = new javax.swing.JComboBox();
        jSeparator2 = new javax.swing.JSeparator();
        jbtnMostrar = new javax.swing.JButton();
        jbtnGrupo = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setResizable(true);

        jbtnGenerarRPT.setBackground(new java.awt.Color(79, 155, 76));
        jbtnGenerarRPT.setFont(new java.awt.Font("DejaVu Sans", 1, 15)); // NOI18N
        jbtnGenerarRPT.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/proyecto/imagenes/pdf_icon.png"))); // NOI18N
        jbtnGenerarRPT.setText("Generar Reporte");
        jbtnGenerarRPT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnGenerarRPTMouseClicked(evt);
            }
        });
        jbtnGenerarRPT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnGenerarRPTActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel1.setText("Unidad:");

        jLabel2.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel2.setText("Materias:");

        jtbleGrupos.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jtbleGrupos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jtbleGrupos.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jScrollPane1.setViewportView(jtbleGrupos);

        jcmbUnidad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione", "I", "II", "III", "IV" }));

        jcmbMaterias2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbMaterias2ItemStateChanged(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel4.setText("Grupo:");

        jtxtGrupo.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N

        jcmbMaterias1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbMaterias1ItemStateChanged(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel6.setText("Plan:");

        jcmbPlan1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jcmbPlan1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbPlan1ItemStateChanged(evt);
            }
        });

        jcmbPlan2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jcmbPlan2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbPlan2ItemStateChanged(evt);
            }
        });

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jbtnMostrar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jbtnMostrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/proyecto/imagenes/mostrar.png"))); // NOI18N
        jbtnMostrar.setText("Mostrar");
        jbtnMostrar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnMostrarMouseClicked(evt);
            }
        });

        jbtnGrupo.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jbtnGrupo.setText("Obtener grupo");
        jbtnGrupo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnGrupoMouseClicked(evt);
            }
        });
        jbtnGrupo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnGrupoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(41, 41, 41)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(68, 68, 68)
                        .addComponent(jcmbUnidad, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(117, 117, 117)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(119, 119, 119)
                        .addComponent(jLabel6))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(100, 100, 100)
                                .addComponent(jLabel2))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jcmbPlan1, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(50, 50, 50)
                                .addComponent(jcmbPlan2, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(160, 160, 160)
                                .addComponent(jcmbMaterias2, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(82, 82, 82)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jbtnMostrar, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addGap(29, 29, 29)
                                        .addComponent(jtxtGrupo, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                    .addComponent(jcmbMaterias1, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(33, 33, 33)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 367, Short.MAX_VALUE)
                        .addComponent(jbtnGenerarRPT, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(24, 24, 24))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jbtnGrupo)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 579, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jbtnGrupo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addComponent(jbtnGenerarRPT)
                .addGap(47, 47, 47))
            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addComponent(jLabel1)
                .addGap(30, 30, 30)
                .addComponent(jcmbUnidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(jLabel6)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcmbPlan1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcmbPlan2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(34, 34, 34)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcmbMaterias1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcmbMaterias2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(51, 51, 51)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtGrupo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jbtnMostrar, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jcmbMaterias2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbMaterias2ItemStateChanged
        ArrayList arry4 = new ArrayList();
        mate = new Materia();
        arry4 = mate.MostrarMaterias_Param_Plan(id_plan2);
        for (int i = 0; i < arry4.size(); i++) {
            entMate = (EntityMateria) arry4.get(i);
            if (this.jcmbMaterias2.getSelectedItem().equals(entMate.getCodigo_asignatura())) {
                id_materia2 = entMate.getId_materia();
            }
        }
    }//GEN-LAST:event_jcmbMaterias2ItemStateChanged
    
    private void jbtnGenerarRPTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnGenerarRPTMouseClicked

    }//GEN-LAST:event_jbtnGenerarRPTMouseClicked
    
    private void jcmbPlan1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbPlan1ItemStateChanged
        ArrayList arry1 = new ArrayList();
        pla = new Plan();
        arry1 = pla.MostrarPlan();
        for (int i = 0; i < arry1.size(); i++) {
            entPla = (EntityPlan) arry1.get(i);
            if (this.jcmbPlan1.getSelectedItem().equals(entPla.getNombre_plan())) {
                id_plan1 = entPla.getId_plan();
            }
        }
        
        CargarComboMaterias1(id_plan1);
        
    }//GEN-LAST:event_jcmbPlan1ItemStateChanged
    
    private void jcmbPlan2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbPlan2ItemStateChanged
        ArrayList arry2 = new ArrayList();
        pla = new Plan();
        arry2 = pla.MostrarPlan();
        for (int i = 0; i < arry2.size(); i++) {
            entPla = (EntityPlan) arry2.get(i);
            if (this.jcmbPlan2.getSelectedItem().equals(entPla.getNombre_plan())) {
                id_plan2 = entPla.getId_plan();
            }
        }
        
        CargarComboMaterias2(id_plan2);
        
    }//GEN-LAST:event_jcmbPlan2ItemStateChanged
    
    private void jcmbMaterias1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbMaterias1ItemStateChanged
        ArrayList arry3 = new ArrayList();
        mate = new Materia();
        arry3 = mate.MostrarMaterias_Param_Plan(id_plan1);
        for (int i = 0; i < arry3.size(); i++) {
            entMate = (EntityMateria) arry3.get(i);
            if (this.jcmbMaterias1.getSelectedItem().equals(entMate.getCodigo_asignatura())) {
                id_materia1 = entMate.getId_materia();
            }
        }
    }//GEN-LAST:event_jcmbMaterias1ItemStateChanged
    
    private void jbtnMostrarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnMostrarMouseClicked
        if (this.id_materia1 != 0 && this.id_materia2 != 0) {

            //Aginando nombre a la variable nombre_materia
            ArrayList arry7 = new ArrayList();
            ArrayList arry8 = new ArrayList();
            mate = new Materia();
            arry7 = mate.MostrarMaterias_Param_Plan(id_plan1);
            arry8 = mate.MostrarMaterias_Param_Plan(id_plan2);

            //Recorriendo arry7
            for (int i = 0; i < arry7.size(); i++) {
                entMate = (EntityMateria) arry7.get(i);
                if (this.jcmbMaterias1.getSelectedItem().equals(entMate.getCodigo_asignatura())) {
                    entNombreMateria1 = entMate.getCodigo_asignatura();
                }
            }

            //Recorriendo arry8
            for (int i = 0; i < arry8.size(); i++) {
                entMate = (EntityMateria) arry8.get(i);
                if (this.jcmbMaterias2.getSelectedItem().equals(entMate.getCodigo_asignatura())) {
                    entNombreMateria2 = entMate.getCodigo_asignatura();
                }
            }
            
            
            
            PopularTable(id_materia1);
        } else {
            JOptionPane.showMessageDialog(rootPane, "Seleccione la materia");
        }
    }//GEN-LAST:event_jbtnMostrarMouseClicked
    
    private void jbtnGrupoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnGrupoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jbtnGrupoActionPerformed
    
    private void jbtnGrupoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnGrupoMouseClicked
        
        try {
            
            int fila = this.jtbleGrupos.getSelectedRow();
            this.jtxtGrupo.setText(String.valueOf(this.jtbleGrupos.getValueAt(fila, 0)));
            id_grupo = Integer.parseInt(this.jtxtGrupo.getText());
            
        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
        
    }//GEN-LAST:event_jbtnGrupoMouseClicked

    private void jbtnGenerarRPTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnGenerarRPTActionPerformed
        if (jcmbUnidad.getSelectedItem().equals("Seleccione")) {
            JOptionPane.showMessageDialog(rootPane, "Seleccione una unidad");
        } else if (this.jcmbPlan1.getSelectedItem().equals("Seleccione")) {
            JOptionPane.showMessageDialog(rootPane, "Seleccione el plan de estudio");
        } else if (this.jcmbPlan2.getSelectedItem().equals("Seleccione")) {
            JOptionPane.showMessageDialog(rootPane, "Seleccione el plan de estudio");
        } else if (jcmbMaterias1.getSelectedItem().equals("Seleccione")) {
            JOptionPane.showMessageDialog(rootPane, "Seleccione una materia");
        } else if (jcmbMaterias2.getSelectedItem().equals("Seleccione")) {
            JOptionPane.showMessageDialog(rootPane, "Seleccione una materia");
        }
        
        if (this.jcmbUnidad.getSelectedItem().equals("I")) {
            int id_materia1 = this.id_materia1;
            int id_materia2 = this.id_materia2;
            int id_grupo = this.id_grupo;
            String nombre_materia = entNombreMateria1.concat("/").concat(entNombreMateria2);
            
            rptUnidad1=new rptIAF_FIS1_U1();
            rptUnidad1.rptUnidad1(id_materia1, id_materia2, id_grupo, nombre_materia);
        }else if(this.jcmbUnidad.getSelectedItem().equals("II")){
           int id_materia1 = this.id_materia1;
            int id_materia2 = this.id_materia2;
            int id_grupo = this.id_grupo;
            String nombre_materia = entNombreMateria1.concat("/").concat(entNombreMateria2);
            
            rptUnidad1=new rptIAF_FIS1_U1();
            rptUnidad1.rptUnidad2(id_materia1, id_materia2, id_grupo, nombre_materia);
         
        }else if(this.jcmbUnidad.getSelectedItem().equals("III")){
           int id_materia1 = this.id_materia1;
            int id_materia2 = this.id_materia2;
            int id_grupo = this.id_grupo;
            String nombre_materia = entNombreMateria1.concat("/").concat(entNombreMateria2);
            
            rptUnidad1=new rptIAF_FIS1_U1();
            rptUnidad1.rptUnidad3(id_materia1, id_materia2, id_grupo, nombre_materia);
         
        }else if(this.jcmbUnidad.getSelectedItem().equals("IV")){
           int id_materia1 = this.id_materia1;
            int id_materia2 = this.id_materia2;
            int id_grupo = this.id_grupo;
            String nombre_materia = entNombreMateria1.concat("/").concat(entNombreMateria2);
            
            rptUnidad1=new rptIAF_FIS1_U1();
            rptUnidad1.rptUnidad4(id_materia1, id_materia2, id_grupo, nombre_materia);
         
        }
    }//GEN-LAST:event_jbtnGenerarRPTActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JButton jbtnGenerarRPT;
    private javax.swing.JButton jbtnGrupo;
    private javax.swing.JButton jbtnMostrar;
    private javax.swing.JComboBox jcmbMaterias1;
    private javax.swing.JComboBox jcmbMaterias2;
    private javax.swing.JComboBox jcmbPlan1;
    private javax.swing.JComboBox jcmbPlan2;
    private javax.swing.JComboBox jcmbUnidad;
    private javax.swing.JTable jtbleGrupos;
    private javax.swing.JTextField jtxtGrupo;
    // End of variables declaration//GEN-END:variables
}
